﻿using DevExpress.Spreadsheet.Functions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UserDefineFunction
{
    static class Help
    {
        internal static ParameterValue ConvertToReturnValue(object obj) {
            switch (obj.GetType().Name)
            {
                case "String":
                    return (string)obj;
                case "Int16":
                case "Int32":
                case "UInt16":
                    return (int)obj;
                case "Double":
                case "Int64":
                case "UInt64":
                case "UInt32":
                    return (double)obj;
                case "SByte":
                    return (sbyte)obj;
                case "Byte":
                    return (byte)obj;
                case "DateTime":
                    return (DateTime)obj;
                case "Char":
                    return (char)obj;
                case "Boolean":
                    return (bool)obj;
                case "Single":
                    return (float)obj;
                case "Decimal":
                    return (decimal)obj;
                default:
                    return "数据类型不受支持";
            }
        }
    }
}
